package com.server.http.handler.impl;

import com.server.conditionenum.HttpReturnStatus;
import com.server.db.DataBaseManager;
import com.server.http.handler.HttpHandler;
import com.server.http.request.HttpRequestMessage;
import com.server.http.response.HttpResponseMessage;
import com.server.mine.net.HttpProtocol;
import com.server.tools.AppData;

/**
* @author	李小布
* @email	397554852@qq.com
* @version	创建时间：2018年9月30日 上午11:28:55
*/
public class RefreshRankList extends HttpHandler{

	@Override
	public void handle(HttpRequestMessage request, HttpResponseMessage response) {
		String failMsg = null;
		int rkid = 0;
		try {
			rkid = Integer.parseInt(request.getParameter("rkid"));
			if(AppData.rankTableMap.containsKey(rkid)) {
				DataBaseManager.GetInstance().RefreshRanklist(AppData.rankTableMap.get(rkid).rkname, AppData.rankDataMap.get(rkid));
			}else {
				failMsg = "排行榜不存在!";
			}
		}catch (Exception e) {
			e.printStackTrace();
			failMsg = "上传的参数错误!";
		}
		if(failMsg == null) {
			SetReturnData(response,"刷新成功!",HttpProtocol.REFRESHRANKLIST,HttpReturnStatus.Successed);
		}else {
			SetReturnData(response,failMsg,HttpProtocol.REFRESHRANKLIST,HttpReturnStatus.Failed);
		}
	}
}
